package cn.fenqing168.springcloud.controller;

import cn.fenqing168.springcloud.commons.BaseResult;
import cn.fenqing168.springcloud.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 账户控制层
 * @author fenqing
 */
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService iAccountService;

    /**
     * 减少账户余额
     * @param userId 用户id
     * @param money 减少金额
     * @return 处理结果
     */
    @PutMapping("/decrease")
    public BaseResult<?> decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        iAccountService.decrease(userId, money);
        return BaseResult.success("减少账户余额成功！");
    }

}
